Double Click Demo

© 2004, Brad Moore, Carl Gundel, Alyce Watson

Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index


One of the difficulties with Liberty Basic occurs in the handling of the double click event when coupled with a click event. It is easy to trap for a click event or to trap for a double click event, but if you are trapping for BOTH a click event and a double click event at the same time, LB always triggers the single click and never triggers the double click.

This is because a double click event always triggers a single click event as it occurs. This was discussed on the Conforums site some weeks ago, and Carl offered a very glamorous solution to the problem using a timer. I improved upon the solution by incorporating the API call to get the user's double click time using a system API and setting the timer to this value. The call is courtesy Alyce Watson.

With permission of Carl and Alyce, this has been placed into the Public Domain. Here is a quick demo that shows the technique in action.



' Determine whether the user single clicked or double clicked
' credit to Carl G for the timer idea and program code
' credit to Alyce W for the DoubleClickTime API call

nomainwin
open "click example" for graphics as #g
#g "when leftButtonUp [click]"
#g "when leftButtonDouble [doubleClick]"
#g "trapclose [quit]"
wait


[click]
'get the user's double click time
timer getDCT(), [clickTimer]
wait

[doubleClick]
timer 0
popupmenu "You double-clicked!", [noOp]
wait

[clickTimer]
timer 0
popupMenu "You single-clicked!", [noOp]
wait

[noOp] 'no operation
wait

[quit]
close #g
end 


function getDCT()
   calldll #user32, "GetDoubleClickTime", clickTime as ulong
   getDCT = clickTime
end function
  


Home

Tip Corner

API Corner

Qcard DLL #5

Sprite Byte

Projectile Motion

Sub Handlers

Agent Lesson

LB Server

A Web Presence

Website Review

An Interview

DoubleClick

Disk Cleaner

Newsletter help

Index